
<?php	
	
	class admin extends database
	{
		var $connection = '';	

		function admin()
		{
			parent::database();
		}
	
		function GetListPaging()
		{						
			$this->setQuery("set names utf8");
			$this->query();
			return $sql = "Select * from tbladmin";			
			//return $pager;
			//$rs = $pager->paginate();
	//Loop through the result set
				
			/*$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;*/
		}
		
		function GetList()
		{						
			$this->setQuery("set names utf8");
			$this->query();			
			$sql = "SELECT * from tbladmin ";			
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
        function GetListAdmin($user, $pass)
		{						
			$this->setQuery("set names utf8");
			$this->query();			
			$sql = "SELECT * from tbladmin where ActiveYN = 'Yes' 
            and Level = '5' and Username = '".$user."' and Password = '".$pass."'";	
           // echo $sql;		
			$this->setQuery($sql);
			$value = $this->loadAllRow();
			return $value;
		}
        function AddAdmin($Username, $Password, $Level, $Email, $FirstName, $LastName, $Phone, $ActiveYN, $CreatedDate)
		{
            $CreatedDate=date('Y-m-d H:i:s', time());
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Insert into tbladmin(`Username`, `Password`, `Level`, `Email`
            , `FirstName`, `LastName`, `Phone`, `ActiveYN`, `CreatedDate`) 
            values('".$Username."', '".$Password."', '".$Level."', '".$Email."', '".$FirstName."'
            , '".$LastName."', '".$Phone."', '".$ActiveYN."', '".$CreatedDate."')";
            //echo $sql;
			$this->setQuery($sql);
			$this->query();
		}
		
		function UpdateAdmin($Username, $Password, $Level, $Email, $FirstName, $LastName, $Phone, $ActiveYN, $id)
		{
 
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Update tbladmin set `Username` =  '".$Username."', 
            `Password` = '".$Password."', `Level` = '".$Level."', 
            `Email` = '".$Email."',`FirstName` = '".$FirstName."',`LastName` = '".$LastName."', 
            `Phone` = '".$Phone."',
            `ActiveYN` = '".$ActiveYN."'";
			$sql .= " where AID=".$id;	
            //echo $sql;		
			$this->setQuery($sql);
			$this->query();
		}
		
		function GetOneAdmin($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "Select * from tbladmin where AID=".$id."";
			$this->setQuery($sql);
			$row = $this->loadOneRow();
			return $row;
		}
		
		function DeleteAdmin($id)
		{
			$this->setQuery("set names utf8");
			$this->query();
			$sql = "";
			$sql = "Delete from tbladmin ";
			$sql .= " where AID=".$id;			
			
			$this->setQuery($sql);
			$this->query();
		}
	
		
	}
?>